<template>
	<view class="mine-container" :style="{height: `${windowHeight}px`}">
		<!--顶部个人信息栏-->
		<view class="header-section">
			<view class="flex padding justify-between">
				<view class="flex align-center">
					<view v-if="!avatar" class="cu-avatar xl round bg-white">
						<view class="iconfont icon-people text-gray icon"></view>
					</view>
					<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round"
						mode="widthFix">
					</image>
					<view v-if="!name" @click="handleToLogin" class="login-tip">
						点击登录
					</view>
					<view v-if="nickname" @click="handleToInfo" class="user-info">
						<view class="u_title">
							{{ nickname }}
						</view>
					</view>
				</view>
				<view @click="handleToInfo" class="flex align-center">
					<text>个人信息</text>
					<view class="iconfont icon-right"></view>
				</view>
			</view>
		</view>

		<view class="content-section">
			<view class="mine-actions grid col-4 text-center">
				<view class="action-item" @click="handleJiaoLiuQun">
					<view class="iconfont icon-friendfill text-pink icon"></view>
					<text class="text">交流群</text>
				</view>
				<view class="action-item" @click="handleBuilding">
					<view class="iconfont icon-service text-blue icon"></view>
					<text class="text">在线客服</text>
				</view>
				<view class="action-item" @click="handleBuilding">
					<view class="iconfont icon-community text-mauve icon"></view>
					<text class="text">反馈社区</text>
				</view>
				<view class="action-item" @tap="tapEvent('/pages/mine/share/mysharecode')">
					<view class="iconfont icon-dianzan text-green icon"></view>
					<text class="text">分享码</text>
				</view>
			</view>
			<view class="bottom-container-one-row-2" >
				<view>
					<text style="font-size: 24rpx;font-weight: 600;">
						我的邀约/奖励
					</text>
				</view>
				<view class="ul-item">
					<view data-index="2" @tap="tapEvent('/pages/mine/share/mysharelist')" data-key="" class="item" hover-class="opcity"
						:hover-stay-time="150">
						<text class="item-title" style="color: #FF7900;">{{shareData.totalAmount}}</text>
						<span class="item-name"><uni-icons type="medal" size="14"></uni-icons>佣金</span>
					</view>
					<view @tap="tapEvent('/pages/mine/share/mysharelist')" data-index="2" data-key="" class="item" hover-class="opcity"
						:hover-stay-time="150">
						<text class="item-title">{{ shareData.shareQty }}</text>
						<!-- <image class='item-img' src='../../static/images/my/mine_icon_jiayouzhan_3x.png'></image> -->
						<span class="item-name"><uni-icons type="staff-filled" size="14"></uni-icons>邀约的人</span>
					</view>
					<view data-index="2"
						data-key="" class="item" hover-class="opcity" :hover-stay-time="150">
						<text class="item-title">{{ shareData.remainAmount }}</text>
						<span class="item-name"><uni-icons type="wallet" size="14"></uni-icons>待提现</span>
					</view>
					<view @tap="toCouponTab" data-index="2" data-key="" class="item" hover-class="opcity"
						:hover-stay-time="150">
						<text class="item-title">{{ shareData.cashOutAmount }}</text>
						<span class="item-name"><uni-icons type="wallet-filled" size="14"></uni-icons>已提现</span>
					</view>
				</view>
			</view>
			<view class="menu-list">
				<view class="list-cell list-cell-arrow" @click="tapEvent('/pages/mine/info/edit')">
					<view class="menu-item-box">
						<view class="iconfont icon-user menu-icon"></view>
						<view>编辑资料</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow" @click="handleHelp">
					<view class="menu-item-box">
						<view class="iconfont icon-help menu-icon"></view>
						<view>常见问题</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow" @click="handleAbout">
					<view class="menu-item-box">
						<view class="iconfont icon-aixin menu-icon"></view>
						<view>关于我们</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow" @click="handleToSetting">
					<view class="menu-item-box">
						<view class="iconfont icon-setting menu-icon"></view>
						<view>应用设置</view>
					</view>
				</view>
			</view>



			<wei-share ref="weiShare" @posterHandle="toPosterPageView"></wei-share>
		</view>
	</view>
</template>

<script>
	import request from '@/utils/request'
	import storage from '@/utils/storage'
	
	export default {
		data() {
			return {
				name: this.$store.state.user.name,
				userid: this.$store.state.user.userid,
				nickname: this.$store.state.user.nickname,
				version: getApp().globalData.config.appInfo.version,
				shareData:{ShareQty:0,TotalAmount:0,ValidAmount:0,RewardAmount:0,CashOutAmount:0,RemainAmount:0,}
			}
		},
		computed: {
			avatar() {
				return this.$store.state.user.avatar
			},
			windowHeight() {
				return uni.getSystemInfoSync().windowHeight - 50
			}
		},
		onLoad(e) {
			this.getShareCode(this.userid);
		},
		methods: {
			// 菜单跳转
			tapEvent: function(url) {
				uni.navigateTo({
					url: url
				});
			},
			getShareCode(userid) {
				let postData = {};
				request({
				  url:'/system/sharecode/list?UserId=' + userid,
				  headers: {
				    isToken: false
				  },
				  method: 'GET'
				}).then(res => {
					if (res.code == 200) {
						this.count =res.total;
						if(res.total>0){
							this.shareData = res.rows[0];
						}
					} else {
						this.tui.toast('失败，' + res.msg);
					}
				})
				.catch(res => {
					console.log(res);
				});
			},
			handleToInfo() {
				this.$tab.navigateTo('/pages/mine/info/index')
			},
			handleToEditInfo() {
				this.$tab.navigateTo('/pages/mine/info/edit')
			},
			handleToSetting() {
				this.$tab.navigateTo('/pages/mine/setting/index')
			},
			handleToLogin() {
				this.$tab.reLaunch('/pages/login')
			},
			handleToAvatar() {
				this.$tab.navigateTo('/pages/mine/avatar/index')
			},
			handleLogout() {
				this.$modal.confirm('确定注销并退出系统吗？').then(() => {
					this.$store.dispatch('LogOut').then(() => {
						this.$tab.reLaunch('/pages/index')
					})
				})
			},
			handleHelp() {
				this.$tab.navigateTo('/pages/mine/help/index')
			},
			handleAbout() {
				this.$tab.navigateTo('/pages/mine/about/index')
			},
			handleJiaoLiuQun() {
				this.$modal.showToast('QQ群：①10000001、②1000000')
			},
			handleBuilding() {
				this.$modal.showToast('模块建设中~')
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f5f6f7;
	}

	.mine-container {
		width: 100%;
		height: 100%;


		.header-section {
			padding: 15px 15px 45px 15px;
			background-color: #3c96f3;
			color: white;

			.login-tip {
				font-size: 18px;
				margin-left: 10px;
			}

			.cu-avatar {
				border: 2px solid #eaeaea;

				.icon {
					font-size: 40px;
				}
			}

			.user-info {
				margin-left: 15px;

				.u_title {
					font-size: 15px;
					line-height: 25px;
				}
			}
		}

		.content-section {
			position: relative;
			top: -50px;

			.mine-actions {
				margin: 15px 15px;
				padding: 20px 0px;
				border-radius: 8px;
				background-color: white;

				.action-item {
					.icon {
						font-size: 28px;
					}

					.text {
						display: block;
						font-size: 13px;
						margin: 8px 0px;
					}
				}
			}
		}
	}
</style>
<style>
	/* pages/my/my.wxss */
	.container {
		position: relative;
	}

	.top-container {
		height: 420rpx;
		position: relative;
		display: flex;
		flex-direction: column;
		background-color: #5677FC;
	}

	.bg-img {
		position: absolute;
		width: 100%;
		height: 440rpx;
	}

	.logout {
		width: 110rpx;
		height: 36rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		margin: 42rpx 0 24rpx 32rpx;
		position: relative;
		z-index: 2;
	}

	.logout-img {
		width: 36rpx;
		height: 36rpx;
		margin-right: 11rpx;
	}

	.logout-txt {
		font-size: 28rpx;
		color: #fefefe;
		line-height: 28rpx;
	}

	.user-wrapper {
		display: flex;
		justify-content: center;
		position: relative;
		z-index: 2;
	}

	.user {
		display: flex;
		flex-direction: column;
		justify-content: center;
		position: relative;
		z-index: 2;
	}

	.avatar-img {
		width: 160rpx;
		height: 160rpx;
		border-radius: 50%;
		align-self: center;
	}

	.user-info {
		display: flex;
		flex-direction: row;
		margin-top: 30rpx;
		align-items: center;
	}

	.user-info-mobile {
		margin-top: 30rpx;
		position: relative;
		font-size: 28rpx;
		color: #fefefe;
		line-height: 28rpx;
		align-self: center;
		padding: 0 50rpx;
	}

	.edit-img {
		position: absolute;
		width: 42rpx;
		height: 42rpx;
		right: 0;
		bottom: -4rpx;
	}

	.edit-img>image {
		width: 42rpx;
		height: 42rpx;
		padding-left: 25rpx;
	}

	.middle-container {
		height: 138rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		border-radius: 10rpx;
		background-color: #ffffff;
		margin: -30rpx 30rpx 26rpx 30rpx;
		box-shadow: 0 15rpx 10rpx -15rpx #efefef;
		position: relative;
		z-index: 2;
	}

	.middle-item {
		height: 100%;
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.ticket-img {
		width: 80rpx;
		height: 80rpx;
		margin-left: 65rpx;
	}

	.middle-tag {
		font-size: 28rpx;
		color: #333333;
		line-height: 28rpx;
		font-weight: bold;
		padding-left: 22rpx;
	}

	.car-img {
		width: 80rpx;
		height: 80rpx;
		margin-left: 97rpx;
	}

	.bottom-container-one-row {
		height: 140rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding: 20rpx 40rpx 20rpx 40rpx;
		/* margin: 10rpx 30rpx; */
		background-color: #ffffff;
		border-radius: 10rpx;
		box-sizing: border-box;
		/* box-shadow: 0 0 10rpx #efefef; */
		/* position: relative; */
		z-index: 2;
		margin: -120rpx 30rpx 10rpx 30rpx;
		box-shadow: 0 15rpx 10rpx -15rpx #efefef;
	}

	.bottom-container-one-row-2 {
		height: 180rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding: 20rpx 40rpx 20rpx 40rpx;
		margin: 10rpx 30rpx;
		background-color: #ffffff;
		border-radius: 10rpx;
		box-sizing: border-box;
		box-shadow: 0 0 10rpx #efefef;
	}

	.bottom-container {
		height: 140rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding: 20rpx 40rpx;
		margin: 0rpx 30rpx;
		background-color: #ffffff;
		border-radius: 10rpx;
		box-sizing: border-box;
		box-shadow: 0 0 10rpx #efefef;
	}

	.bottom-container-mer {
		height: 200rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		padding: 20rpx 40rpx;
		margin: 0rpx 30rpx;
		background-color: #ffffff;
		border-radius: 10rpx;
		box-sizing: border-box;
		box-shadow: 0 0 10rpx #efefef;
	}

	.ul-item {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.item {
		display: flex;
		flex-direction: column;
		align-items: center;
		position: relative;
	}

	.item-img {
		width: 64rpx;
		height: 64rpx;
	}

	.item-name {
		padding-top: 4rpx;
		font-size: 24rpx;
		color: #666666;
		min-width: 80rpx;
		text-align: center;
	}

	.item-name-orange {
		padding-top: 4rpx;
		font-size: 24rpx;
		color: #FF7900;
		min-width: 80rpx;
		text-align: center;
		font-weight: 800;
	}

	.btn-feedback {
		background: transparent !important;
		position: absolute;
		height: 100%;
		width: 100%;
		left: 0;
		top: 0;
	}

	.item-title {
		font-weight: bold;
		font-size: 32rpx;
		color: #5677fc;
	}

	.item-title-big {
		font-weight: bold;
		font-size: 32rpx;
		color: #FF7900;
	}
</style>